#逛逛app接口php环境构建脚本
#Version 1.0

#Base images
FROM centos:7

#MAINTAINER
MAINTAINER 475281441@qq.com

#  设置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#ADD
ADD	php-7.2.29.tar.gz /usr/local/
ADD	./ext/mongodb-1.7.4.tar /usr/local/
ADD	./ext/redis-5.2.1.tar /usr/local/

#RUN
#RUN sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf
RUN yum install -y install epel-release
RUN yum -y install git wget lrzsz vim  libxml2 libxml2-devel openssl openssl-devel curl curl-devel libjpeg-turbo libjpeg-turbo-devel libpng-devel libpng freetype-devel freetype icu libicu-devel libicu libmcrypt libmcrypt-devel libxslt libxslt-devel php-mysql && \
    yum -y groupinstall "Development Tools" && \
    yum provides "*/applydeltarpm" && \
    yum install deltarpm -y && \
    yum clean all && \
    groupadd www && \
    useradd -g www www

#WORKDIR
WORKDIR /usr/local/php-7.2.29

RUN ./configure --prefix=/usr/local/php72 \
    --with-config-file-path=/usr/local/php72/etc \
    --with-config-file-scan-dir=/usr/local/php72/conf.d \
    --enable-fpm --with-fpm-user=www \
    --with-fpm-group=www \
    --with-mysql=mysqlnd \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd \
    --with-iconv-dir \
    --with-freetype-dir=/usr/local/freetype \
    --with-jpeg-dir \
    --with-png-dir \
    --with-zlib \
    --with-libxml-dir=/usr \
    --enable-xml \
    --disable-rpath \
    --enable-bcmath \
    --enable-shmop \
    --enable-sysvsem \
    --enable-inline-optimization \
    --with-curl \
    --enable-mbregex \
    --enable-mbstring \
    --with-mcrypt \
    --enable-ftp \
    --with-gd \
    --enable-gd-native-ttf \
    --with-openssl \
    --with-mhash \
    --enable-pcntl \
    --enable-sockets \
    --with-xmlrpc \
    --enable-zip \
    --enable-soap \
    --with-gettext \
    --enable-fileinfo \
    --enable-opcache \
    --enable-intl \
    --with-xsl && \
    make -j 4 && make install && \
    cp /usr/local/php72/etc/php-fpm.conf.default /usr/local/php72/etc/php-fpm.conf && \
    cp ./php.ini-production  /usr/local/php72/etc/php.ini && \
    cp /usr/local/php72/etc/php-fpm.d/www.conf.default /usr/local/php72/etc/php-fpm.d/www.conf && \
    cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm && \
    chmod +x /etc/init.d/php-fpm
WORKDIR /usr/local
RUN rm -rf php-7.2.29

WORKDIR /usr/local/mongodb-1.7.4
RUN /usr/local/php72/bin/phpize&&./configure --with-php-config=/usr/local/php72/bin/php-config&&make && make install

WORKDIR /usr/local/redis-5.2.1
RUN /usr/local/php72/bin/phpize&&./configure --with-php-config=/usr/local/php72/bin/php-config&&make && make install

EXPOSE 9000
CMD ["/usr/local/php72/sbin/php-fpm", "-F"]
